package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.CheckInConfigDto;
import com.zzyl.dto.CheckInDto;
import com.zzyl.dto.ContractDto;
import com.zzyl.service.CheckInConfigService;
import com.zzyl.service.CheckInService;
import com.zzyl.service.ContractService;
import com.zzyl.vo.retreat.TasVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkIn")
@Api(tags = "入住")
public class CheckInController {
    @Autowired
    private CheckInService checkInService;

    @Autowired
    private ContractService contractService;

    /**
     * 申请入住
     * @param checkInDto
     * @return
     */
    @PostMapping("/create")
    @ApiOperation("申请入住")
    public ResponseResult createCheckIn(@RequestBody CheckInDto checkInDto){
        return checkInService.createCheckIn(checkInDto);
    }

    /**
     * 查询入住表单
     * @param assigneeId
     * @param code
     * @param flowStatus
     * @param taskId
     * @return
     */
    @GetMapping
    @ApiOperation("查询入住表单")
    public ResponseResult<TasVo> getCheckIn(String assigneeId, String code, Integer flowStatus, String taskId){
        return checkInService.getCheckIn(assigneeId,code,flowStatus,taskId);
    }

    /**
     * 查询评估数据
     * @param checkInDto
     * @return
     */
    @PostMapping("/review")
    @ApiOperation("查询评估数据")
    public ResponseResult review(@RequestBody CheckInDto checkInDto){
        return checkInService.review(checkInDto);
    }

    /**
     * 院长同意
     * @param id
     * @param taskId
     * @param message
     * @return
     */
    @PutMapping("/submit")
    @ApiOperation("院长同意")
    public ResponseResult submitCheckIn(Long id, String taskId, String message) {
        return checkInService.submitCheckIn(id, taskId, message);
    }

    /**
     * 院长拒绝
     * @param id
     * @param taskId
     * @param message
     * @return
     */
    @PutMapping("/reject")
    @ApiOperation("院长拒绝")
    public ResponseResult auditReject(Long id, String taskId, String message){
        return checkInService.auditReject(id,taskId,message);
    }

    /**
     * 院长驳回
     * @param id
     * @param taskId
     * @param message
     * @return
     */
    @PutMapping
    @ApiOperation("院长驳回")
    public ResponseResult disapprove(Long id, String taskId, String message){
        return checkInService.disapprove(id,taskId,message);
    }

    /**
     * 院长撤回
     * @param id
     * @param taskId
     * @param message
     * @return
     */
    @PutMapping("/revocation")
    @ApiOperation("院长撤回")
    public ResponseResult revocation(Long id, String taskId, String message){
        return checkInService.revocation(id,taskId,message);
    }

    /**
     * 申请人撤销
     * @param id
     * @param taskId
     * @return
     */
    @PutMapping("/cancel")
    @ApiOperation("申请人撤回")
    public ResponseResult cancel(Long id, String taskId){
        return checkInService.cancel(id,taskId);
    }

    @Autowired
    private CheckInConfigService checkInConfigService;

    /**
     * 保存入住配置
     * @param checkInConfigDto
     * @return
     */
    @PostMapping
    @ApiOperation("入住配置")
    public ResponseResult checkIn(@RequestBody CheckInConfigDto checkInConfigDto){
        return checkInConfigService.checkIn(checkInConfigDto);
    }

    /**
     * 签约
     * @param contractDto
     * @return
     */
    @PostMapping("/sign")
    public ResponseResult sign(@RequestBody ContractDto contractDto){
        return contractService.sign(contractDto);
    }
}
